package com.tianze.tzkf.app;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.support.multidex.MultiDex;


/**
 * Created by Zcyang on 2018/12/22.
 */

public class App extends Application {

    public static Context context;
    public static Handler handler;
    public static Thread mainThread;
    public static int mainThreadId;
    private static App instance;



    @Override
    public void onCreate() {
        super.onCreate();

        context = this.getApplicationContext();
        handler = new Handler();
        mainThread = Thread.currentThread();
        mainThreadId = android.os.Process.myTid();







        //APP前后台状态监听
        registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
            @Override
            public void onActivityStopped(Activity activity) {



            }

            @Override
            public void onActivityStarted(Activity activity) {




            }

            @Override
            public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
            }

            @Override
            public void onActivityResumed(Activity activity) {
            }

            @Override
            public void onActivityPaused(Activity activity) {
            }

            @Override
            public void onActivityDestroyed(Activity activity) {
            }

            @Override
            public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
//                ActivityStackManager.getInstance().addActivity(activity);
            }
        });

    }

    public static App getInstance() {
        if (instance == null) {
            instance = new App();
        }
        return instance;
    }

    public static Context getAppContext() {
        return App.context;
    }


    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        //方法数超出上限处理
        MultiDex.install(this);
    }
}

